{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <div class="row">
                <!--搜索框开始-->
                <div class="col-sm-12">
                    <div class="layui-form layui-form-item">

                        <div class="layui-input-inline" style="margin-top: 5px">
                            <select name="user_sheng" lay-search="" class="layui-input search" id="province"  lay-filter="province">
                                <option value="">---- 请选择省 ----</option>
                                {foreach name="province" item="vo"}
                                <option value="{$vo.district_id}" >{$vo.district}</option>
                                {/foreach}
                            </select>
                        </div>

                        <div class="layui-input-inline" style="margin-top: 5px">
                            <select name="user_shi" lay-search="" class="layui-input search"  id="city"  lay-filter="city">
                                <option value="">---- 请选择市 ----</option>
                            </select>
                        </div>

                        <div class="layui-input-inline" style="margin-top: 5px">
                            <select name="user_qu" lay-search="" class="layui-input search"  id="district"  lay-filter="district">
                                <option value="">---- 请选择区 ----</option>
                            </select>
                        </div>

                        <div class="layui-input-inline layui-form" style="margin-top: 5px">
                            <select name="user_gender" class="layui-input">
                                <option value="" >不限性别</option>
                                <option value="1">男</option>
                                <option value="2">女</option>
                                <option value="3">未知</option>
                            </select>
                        </div>

                        <div class="layui-input-inline" style="margin-top: 5px">
                            <input type="text"  name="start_time" onfocus="wk.lay_date(this);"  class="layui-input layer-date search" placeholder="注册开始时间" />
                        </div>

                        <div class="layui-input-inline" style="margin-top: 5px">
                            <input type="text"  name="end_time" onfocus="wk.lay_date(this);"  class="layui-input layer-date search" placeholder="注册结束时间" />
                        </div>

                        <div class="layui-input-inline" style="margin-top: 5px">
                            <input type="text"  name="login_start_time" onfocus="wk.lay_date(this);"  class="layui-input layer-date search" placeholder="最后登录开始时间" />
                        </div>

                        <div class="layui-input-inline" style="margin-top: 5px">
                            <input type="text"  name="login_end_time" onfocus="wk.lay_date(this);"  class="layui-input layer-date search" placeholder="最后登录结束时间" />
                        </div>

                        <div class="layui-col-md6 layui-input-inline" style="margin-top: 5px">
                            <input type="text" class="layui-input search" name="keyword" placeholder="用户ID|手机号|姓名|昵称"/>
                        </div>

                        <div class="layui-input-inline" style="margin-top: 5px">
                            <button class="layui-btn" lay-submit="" lay-filter="LAY-search">立即搜索</button>
                            <button  class="layui-btn layui-btn-normal" id="empty"  lay-submit="" lay-filter="LAY-search">重置</button>
                        </div>
                    </div>
                </div>

                <div class="col-sm-12">
                    <div class="input-group" >

                        <button  class="btn btn-danger m-l-xs" href="javascript:;" data-toggle="dropdown">
                        <i class="fa fa-wrench"></i> 导出数据 <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu layui-anim layui-anim-upbit" role="menu">
                        <li><a  href="javascript:;" class="layuiBtn" data-type="excelAll"><i class="fa fa-external-link"></i> 导出选中数据</a></li>
                        <li><a  href="javascript:;" class="layuiBtn" data-type="excelAllNoSelect"><i class="fa fa-external-link"></i> 全部导出</a></li>
                        </ul>

                    </div>
                </div>
                <!--搜索框结束-->
            </div>
            <div class="hr-line-dashed"></div>

            <div class="example-wrap">
                <div class="example">
                    <table class="layui-hide" id="test" lay-filter="demo"></table>

                    <!--操作模板-->
                    <script type="text/html" id="user_gender">
                    {{# if(d.user_gender == 1){ }}
                    男
                    {{# } }}
                    {{# if(d.user_gender == 2){ }}
                    女
                    {{# } }}
                    {{# if(d.user_gender == 3){ }}
                    未知
                    {{# } }}
                    </script>

                    <script type="text/html" id="opeBar">
                        <a href="javascript:;" onclick="wk.layer_show('详情', '{:url('userDetail')}?user_id={{d.user_id}}')" class="btn btn-primary btn-xs m-r-xs" title="详情">详情</a>
                        <a href="javascript:;" onclick="wk.layer_show('编辑', '{:url('userEdit')}?user_id={{d.user_id}}')" class="btn btn-primary btn-xs m-r-xs" title="编辑">编辑</a>
<!--                        <a href="javascript:;" onclick="wk.layer_show('充值', '{:url('userRecharge')}?user_id={{d.user_id}}')" class="btn layui-btn-normal btn-xs m-r-xs" title="充值">充值</a>-->

                        {{# if(d.user_status == 1){ }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.user_id}}','{:url('userFreeze')}','确定冻结吗?')" class="btn btn-danger btn-xs m-r-xs" title="冻结">冻结</a>
                        {{# } }}

                        {{# if(d.user_status == 2){ }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.user_id}}','{:url('userUsing')}','确定启用吗?')" class="btn btn-warning btn-xs m-r-xs" title="启用">启用</a>
                        {{# } }}

<!--                        <a href="javascript:;" onclick="wk.layer_show('收货地址', '{:url('userAddress')}?user_id={{d.user_id}}')" class="btn btn-primary btn-xs m-r-xs" title="收货地址">收货地址</a>-->
<!--                        <a href="javascript:;" onclick="wk.layer_show('下级', '{:url('userLower')}?user_id={{d.user_id}}')" class="btn btn-primary btn-xs m-r-xs" title="下级">下级</a>-->
<!--                        <a href="javascript:;" onclick="wk.layer_show('佣金', '{:url('userYj')}?user_id={{d.user_id}}')" class="btn btn-primary btn-xs m-r-xs" title="佣金">佣金</a>-->
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    //layui渲染数据表格
    layui.use('table', function () {
        var table = layui.table
                , form = layui.form;
        table.render({
            elem: '#test'
            , url: '{:url("Memberh/index")}'
            ,response: {
                statusCode: 220 //成功的状态码，默认：0
            }
            , page: true
            , size: 'lg' //sm小尺寸的表格 lg大尺寸
            , cellMinWidth: 150
            , limits: [5, 10, 15, 20, 25, 300]
            , limit: "{:config('pages')}"
            , loading: true
            , id: 'testReload'
            , cols: [[
                {type: 'checkbox', fixed: 'left'},
                  // {type:'numbers', width: 60, title: '序号'}
                {field: 'user_id', width: 80, title: 'ID', align: 'center'}
                , {field: 'user_username', width: 100, title: '昵称', align: 'center'}
                , {field: 'user_phone', width: 120, title: '手机号', align: 'center'}
                , {field: 'user_real_name', width: 100, title: '姓名', align: 'center'}
                , {field: 'user_gender', width: 70, title: '性别', align: 'center',templet: '#user_gender'}
                , {field: 'user_area_str', width: '', title: '地址', align: 'center'}
                , {field: 'user_time', width: 160, title: '注册时间', align: 'center'}
                , {field: 'user_last_login', width: 160, title: '最后登录时间', align: 'center'}
                , {fixed: 'right', width:200, title: '操作', align: 'center', toolbar: '#opeBar'}
            ]]
            ,done: function (res, curr, count) {
                $('.aaasss').viewer({
                    url: 'data-original'
                });
            }
        });
        //批量操作
        var $ = layui.$, active = {
            //批量导出订单
            excelAll:function () {
                wk.excelAll(getIds(),$('.layui-input').serialize(),"{:url('outExcel')}");
            },
            //全部导出
            excelAllNoSelect:function () {
                wk.excelAllNoSelect(-1,$('.layui-input').serialize(),"{:url('outExcel')}");
            }
        };
        $('.layuiBtn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        var getIds = function () {
            var ids = [];
            var checkStatus = table.checkStatus('testReload')
                    ,data = checkStatus.data;
            $.each(data,function(index,item){
                ids.push(item['user_id'])
            });
            return ids;
        }
    });
</script>
</body>
</html>